


module Demo01 where

import ContML.CPS
import ContML.CPSTrafo
import ContML.FreshMon
import ContML.Parser
import qualified ContML.Syntax as ML
import ContML.Types
import ContML.VarId



import Text.PrettyPrint                 -- package: pretty

import Control.Applicative


demo01 :: IO ()
demo01 = putStrLn $ render $ ML.ppExpr term01



term01 :: ML.Expr
term01 = ML.Fun x (ML.App (ML.Var f) (ML.Pair (ML.Var x) (ML.Var y)))
  where
    x = VarId "x" TyUnit
    y = VarId "y" TyUnit
    f = VarId "f" (TyFun (TyPair TyUnit TyUnit) TyUnit)
    

demo02 = either error sk $ parseML "fn x => (x,x)"
  where
    sk e1 = do { putStrLn $ render $ ML.ppExpr e1
               ; putStrLn $ show e1
               ; putStrLn $ render $ ppTerm $ cpsTraf e1
               }
    
    cpsTraf e = runMon (cps e)